<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1">
<jsp:directive.page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<jsp:directive.page import="java.util.ArrayList, java.util.Iterator, cult.ticketing.bean.*" />
<jsp:output omit-xml-declaration="no" doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />

<jsp:text><![CDATA[
<form name="stats" id="stats" method="post" action="]]></jsp:text><jsp:expression>request.getContextPath()</jsp:expression><jsp:text><![CDATA[/index.do">
    <input type="hidden" name="todo" id="todo" value="prepareViewStatistics" />
    <table class="stats">
    <tbody>]]></jsp:text>
        
    <jsp:text><![CDATA[<b>]]></jsp:text><jsp:expression>((Movie)request.getAttribute("movie")).getTitle()</jsp:expression><jsp:text><![CDATA[</b><br />]]></jsp:text>

    <jsp:scriptlet>
      ArrayList&lt;ScheduleItem&gt; scheduleItems = (ArrayList&lt;ScheduleItem&gt;)request.getAttribute("scheduleItems");
      Movie movie = (Movie)request.getAttribute("movie");
      Iterator&lt;ScheduleItem&gt; it = scheduleItems.iterator();
      int count = 0;
      int[] validSeatNum = (int[])request.getAttribute("validSeatNum");
      int[] bookedSeatNum = (int[])request.getAttribute("bookedSeatNum");
      while (it.hasNext() != false) {
        pageContext.setAttribute("scheduleItem", (ScheduleItem)it.next());
    </jsp:scriptlet>
    <jsp:useBean id="scheduleItem" type="cult.ticketing.bean.ScheduleItem" scope="page" />

    <jsp:text><![CDATA[
        <tr>
            <td>]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="houseId" />
            <jsp:text><![CDATA[</td>

            <td>]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="showTime" />
            <jsp:text><![CDATA[</td>

            <td> HKD]]></jsp:text>
            <jsp:getProperty name="scheduleItem" property="price" />
            <jsp:text><![CDATA[</td>

            <td>Total Seat Number: ]]></jsp:text>
            <jsp:expression>validSeatNum[count]</jsp:expression>
            <jsp:text><![CDATA[</td>

            <td>Purchased Seat Number: ]]></jsp:text>
            <jsp:expression>bookedSeatNum[count]</jsp:expression>
            <jsp:text><![CDATA[</td>

            <td>Rate: ]]></jsp:text>
            <jsp:expression>
            ((double)Math.round((double)bookedSeatNum[count]/validSeatNum[count]*10000)/10000)*100
            </jsp:expression>
            <jsp:text><![CDATA[%</td>

        </tr>]]></jsp:text>
    
        <jsp:scriptlet>
            pageContext.removeAttribute("scheduleItem");
            pageContext.removeAttribute("stat");
            count ++;

        }
        </jsp:scriptlet>
        <jsp:text><![CDATA[</tbody>

    </table>
    <input type="submit" value="OK" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>

</form>]]></jsp:text>
</jsp:root>